#!/bin/sh
#update the pear package statistics and unit tests
cd '/data/pear/'
source ./settings.sh

echo "updating peardoc from CVS"
cd $cvs_peardoc
cvs update -Pd
./configure

echo "updating pear from CVS"
cd $cvs_pear
cvs update -Pd

echo "updating pearweb from CVS"
cd $cvs_pearweb
cvs update -Pd

echo "updating I18N_UnicodeNormalizer from SVN"
cd "$cvs_pear/I18N_UnicodeNormalizer"
svn update

echo "updating PHP_Beautifier from SVN"
cd "$cvs_pear/PHP_Beautifier"
#svn co https://beautifyphp.svn.sourceforge.net/svnroot/beautifyphp/trunk/ PHP_Beautifier
svn update

echo "updating PHP_DocBlockGenerator from SVN"
cd "$cvs_pear/PHP_DocBlockGenerator"
svn update

echo "updating QA_PEAR_CI from SVN"
cd "$cvs_pear/QA_PEAR_CI"
svn update


echo "generating documentation coverage"
cd $doccoverage
./genAll.sh

echo "generating package status"
cd $packagestats
./genSimple.sh


if [ ! -d "$www_coverage" ]; then
    mkdir "$www_coverage"
fi
if [ ! -d "$www_packagestatus" ]; then
    mkdir "$www_packagestatus"
fi

cp $doccoverage/*.html "$www_coverage"
cp $packagestats/*.html "$www_packagestatus"

#unit tests
cd "$cmddir"
./runUnitTests.sh
./createSloccount.sh
./runPHPCS.sh

cd "$cmddir"
echo "generating overview"
./createStatusOverview.sh



rm "$www/lastupdate"
touch "$www/lastupdate"
php -r 'echo date("c");' > "$www/lastupdate"

echo "statistics finished"
